using System;
using System.Collections.Generic;
using CMS.Core.DataInterfaces;
using CMS.Core.Domain;
using NHibernate.Criterion;
using NHibernate;

namespace CMS.Data
{
    public class ThongBaoDao : AbstractNHibernateDao<ThongBao, System.Int32>, IThongBaoDao
    {
        #region Create Instance
        private static ThongBaoDao instance = null;
        public static ThongBaoDao Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ThongBaoDao();
                }
                return instance;
            }
        }
        #endregion     

        public List<ThongBao> GetThongBaoTop5()
        {
            List<ThongBao> results = null;
            ICriteria criteria = NHibernateSessionManager.Instance.GetSession().CreateCriteria(typeof(ThongBao));
            criteria.SetFirstResult(0);
            criteria.SetMaxResults(5);
            //criteria.Add(Restrictions.Eq("TrangThai", true));
            criteria.AddOrder(NHibernate.Criterion.Order.Desc("NgayCapNhat"));

            results = criteria.List<ThongBao>() as List<ThongBao>;
            return results;
        }

    }
}
